<?php
// +----------------------------------------------------------------------
// | zbshop [ 小程序商城 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019 烛照科技 All rights reserved.
// +----------------------------------------------------------------------
// | Author: workrd <304609001@qq.com>
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\Room;
use think\facade\Log;

class Notify extends Api
{
    /**
     *  录制视频回调
     * @return mixed
     */
    public function index()
    {
        if($this->request->isPost()){
            $data=file_get_contents("php://input");
            if(empty($data)){
                Log::info('data is empty');
                return 'data is empty';
            }
            $data=json_decode($data,true);
            $live=\app\common\model\Live::where('stream_name',$data['stream'])->find();
            if($live){
                $live->play_name=$data['uri'];
                $live->utime=time();
                $live->save();
                Room::where('id',$live->room_id)->update(['is_live'=>0,'utime'=>time()]);
            }
            return $data;
        }
    }
}